﻿Public Class CommonClass
    Public Shared Sub fillDepreciationDropDown(ByRef ddlToFill As ComboBox, ByVal blnBlank As Boolean, ByVal blnDefault As Boolean)
        Dim al As ArrayList = New ArrayList()
        If blnBlank Then
            al.Add(New MyObject(0, ""))
        End If
        al.Add(New MyObject(1, "Straight-Line"))
        al.Add(New MyObject(2, "Sum of Years"))
        al.Add(New MyObject(3, "Double Declining Balance"))
        al.Add(New MyObject(4, "Percentage Annualy"))
        al.Add(New MyObject(5, "150% Declining Balance"))

        'Set DataBinding
        ddlToFill.DisplayMemberPath = "Name"
        ddlToFill.SelectedValuePath = "ID"
        ddlToFill.ItemsSource = al

        If blnDefault Then
            ddlToFill.SelectedValue = 0
        End If
    End Sub

    Public Class MyObject
        Public Sub New(ByVal id As Integer, ByVal name As String)
            _name = name
            _id = id
        End Sub
        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal Value As String)
                _name = Value
            End Set
        End Property
        Dim _name As String

        Public Property ID() As Integer
            Get
                Return _id
            End Get
            Set(ByVal Value As Integer)
                _id = Value
            End Set
        End Property
        Dim _id As Integer
    End Class

    Public Class MyObjectString
        Public Sub New(ByVal id As String, ByVal name As String)
            _name = name
            _id = id
        End Sub
        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal Value As String)
                _name = Value
            End Set
        End Property
        Dim _name As String

        Public Property ID() As String
            Get
                Return _id
            End Get
            Set(ByVal Value As String)
                _id = Value
            End Set
        End Property
        Dim _id As String
    End Class

End Class

